AttachmentCurd = Ext.extend(RockyGridCurd, {
	conciseMode: true,
	trackMouseOver : true,
	autoWidth : true,
	autoHeight : false,
	loadMask : false,
	closable : true,
	height:300,	
	baseUrl : 'attachment.action',	
	winCfg :{
		height : 560,
		width : 560,
		maximizable:true, 
		title : "内容详细信息"
	},
	viewConfig: {
		forceFit: false
	},		
	win :null, 
	fp : null,
	constructor:function(config){
		Ext.apply(this,config);
		var sm = new Ext.grid.CheckboxSelectionModel();	
		var cmpId = this.id;
		this.cm = new Ext.grid.ColumnModel([
				new Ext.grid.RowNumberer(),sm,
				{
					header : "名称",
					sortable : true,
					width : 150,
					renderer : function(v, p, rec) {						
						return String.format('<a href="../{0}" target="_blank">{1}</a>', rec.data.relativePath.replace(/\\/g,   "/"), v.replace(/\\/g,   "/"))
					},
					dataIndex : "displayName"
				},
				{
					header : "路径",
					width : 300,
					sortable : true,				
//					width : Ext.grid.GridView.autoFill,
					dataIndex : "relativePath"
				}, {
					header : "大小",
					width : 80,
					sortable : true,
					
					renderer : Ext.util.Format.fileSize,
					dataIndex : "size"
				}, {
					header : "上传时间",
					sortable : true,
					width : 80,
					dataIndex : "createTime"			
				}]);
		this.cm.defaultSortable = true;
		this.store = new Ext.data.JsonStore( {
			id : "id",
			url : this.baseUrl + '?cmd=read',
			baseParams:{
				suc:'attachment',
				type:this.type||'',
				id:this.familyid||''
			}, 
			root : "data",
			totalProperty : "rowCount",
			remoteSort : false,
			fields : ["name", "memo", "createTime", "size", "keyword", "id",
					"displayName", "relativePath","modifyTime"]
		});
		AttachmentCurd.superclass.constructor.call(this, {
			sm: sm,
			cm : this.cm,
			store : this.store,
	
			tbar : ['   ', {
				text : '上传',
				iconCls:'add',
				handler : this.create,
				scope : this		
			}, '   ', {
				text : '删除',
				iconCls:'remove',
				handler : this.removeData,
				scope : this
			}, '   ', {
				id:'changRowBody_attachment',
				text : '显示图片',
				iconCls:'option',
				handler : this.changeRowBody,
				scope : this				
			}, '   ', {
				text : '刷新',
				iconCls:'refresh',	
				handler : this.refresh,
				scope : this
			}, new Ext.Toolbar.Fill(), '请输入关键字: ', {
				xtype : "textfield",
				width : 100,		
				scope : this
			}, {
				text : '查询',	
				iconCls:'search',
				handler : this.search,
				scope : this
			}, {
							text : '重置',
							iconCls:'cancel',
							pressed : true,
							handler : this.onReset,						
							scope : this				
			}, '   '],
			bbar : new Ext.PagingToolbar( {
				pageSize : 10,
				store : this.store,
				displayInfo : true,
				displayMsg : '显示{0}-{1}，共{2}条记录',
				emptyMsg : "没有可显示的记录！"
			})
		});
		//this.store.load();		
	},
	edit : function() {
		return false;
	},
	create:function(){		
		this.fileupload = new ExtSWFUpload( {
			upload_url : Rocky.loginuser.upload_url,
			flash_url : Rocky.loginuser.flash_url,
			params : {id:this.archiveid||'',type:this.type}
		});
		this.fileupload.on('close',this.closeFileupload,this);
		this.fileupload.show();		
	},
	closeFileupload:function(){
		if(this.fileupload){
			this.fileupload.destroy();
			this.fileupload=null;			
		}
		this.store.reload();
	},
	changeRowBody:function(){
		this.conciseMode=!this.conciseMode;
		Ext.getCmp('changRowBody_attachment').setText(Ext.getCmp('changRowBody_attachment').getText().toggle('显示信息图片', '不显示信息图片'));
		this.refresh();
	}
});
